/*
 * Copyright 2013 Glassy Cinema.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package hu.glassy.web.panel.help;

import hu.glassy.web.component.common.CustomAjaxLinkPanel;
import hu.glassy.web.panel.common.CustomPanel;
import java.util.Collections;
import org.apache.velocity.app.VelocityEngine;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.spring.injection.annot.SpringBean;
import org.springframework.ui.velocity.VelocityEngineUtils;

/**
 * Súgót megjelenítő oldal
 *
 * @author molnar.alexander@sonrisa.hu
 */
public class HelpPanel extends CustomPanel<Panel>
{

  private static final long serialVersionUID = -6654510010898326643L;
  /**
   * Velocity Engine to handle templates
   */
  @SpringBean
  private VelocityEngine velocityEngine;

  public HelpPanel(final String id)
  {
    super(id);

    // Get the content of the help page...
    final String helpContent = VelocityEngineUtils.mergeTemplateIntoString(velocityEngine, "gamehelp.vm", "UTF-8",
            Collections.<String, Object>emptyMap());

    add(new Label("helpContent", helpContent).setEscapeModelStrings(false));

    add(new CustomAjaxLinkPanel("backButton", new ResourceModel("go.back"))
    {
      private static final long serialVersionUID = 1L;

      @Override
      public void onLinkClick(final AjaxRequestTarget target)
      {
        getMainPage().goBack(target);
      }

      @Override
      public boolean isVisible()
      {
        return getMainPage().isGoBackAllowed();
      }
    });
  }
  // --------------------------------------------------
  // ~ Overrided methods
  // --------------------------------------------------
  // --------------------------------------------------
  // ~ Private methods
  // --------------------------------------------------
  // --------------------------------------------------
  // ~ Protected methods
  // --------------------------------------------------
  // --------------------------------------------------
  // ~ Public methods
  // --------------------------------------------------
  // --------------------------------------------------
  // ~ Abstract methods
  // --------------------------------------------------
  // --------------------------------------------------
  // ~ Inner Class
  // --------------------------------------------------
}
